package com.yun.zf.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yun.zf.admin.mapper.ZfCommunityStatisticalMapper;
import com.yun.zf.admin.service.ZfCommunityStatisticalService;
import com.yun.zf.common.admin.dto.community.CommunityStatisticalDto;
import com.yun.zf.common.app.domain.ZfCommunityStatistical;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 小区统计表 服务实现类
 * </p>
 *
 * @author cj
 * @since 2021-05-20
 */
@Service
public class ZfCommunityStatisticalServiceImpl extends ServiceImpl<ZfCommunityStatisticalMapper, ZfCommunityStatistical> implements ZfCommunityStatisticalService {

    @Override
    public int deleteFromDate(Date date) {
        String start = DateFormatUtils.format(date,"yyyy-MM-dd hh:mm:ss");
        QueryWrapper<ZfCommunityStatistical> statisticalQueryWrapper = new QueryWrapper<>();
        statisticalQueryWrapper.apply("1=1");
       // statisticalQueryWrapper.apply("UNIX_TIMESTAMP(create_time) < UNIX_TIMESTAMP('" + start + "')");
        return baseMapper.delete(statisticalQueryWrapper);
    }

    @Override
    public List<CommunityStatisticalDto> getStatistical(Long communityId) {
        return baseMapper.getStical(communityId);
    }
}
